package gupao.concurrency.kms;

import gupao.concurrency.utils.RSAUtil;

import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.HashMap;
import java.util.Map;

import static gupao.concurrency.utils.RSAUtil.getPublicKey;

public class KeyHolderMock {
    static final String RF_PRIVATE_KEY = "MIIBVgIBADANBgkqhkiG9w0BAQEFAASCAUAwggE8AgEAAkEAl9pCvP3hJJMU0Ix3Sxnj/umt5/wh4yTTXgmf0e2R9+gB9IeljWxGSjHeSYAorsKRL/VMba9qrRo7z14xkKifeQIDAQABAkA+vSGXvfj4SIBwDaj38XF+j4OXdld15nAhyS4r6NDHMIKwQBHWNmsDHhRbc7U6nPE/Go7Yvnzo8ij5+QfrskbRAiEA4i+Sm9Z6qlMvlLg5tg656Y+Y/BsCrT61+L0z//mEIZUCIQCr3mH2byc5Q5vLwE0lAoxbiTfA7GSCvi/nUrOH81dVVQIhAJHX/v7BM2M0NE/+4ieEI1h4oTqd6AHxl8CFr0v0hcBpAiEAkWsg4h0cR/Rvbs8vtr/YOF76wI6DYKhA6e3sn3wCid0CIQCPfmLvESoY89J9hru5BwI/ZLrtHFN6165YhYEZ+Fs0+w==";
    static final String  RF_PUBLIC_KEY = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJfaQrz94SSTFNCMd0sZ4/7pref8IeMk014Jn9HtkffoAfSHpY1sRkox3kmAKK7CkS/1TG2vaq0aO89eMZCon3kCAwEAAQ==";

    static final String MY_PRIVATE_KEY = "MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEApgY3fGDWL16j47djrX4XRCXuNHSLsv/q0x13L+QzN6ZpN6Eroq9owZbBSGWn4bMliQ8Pu1I+XGeyK0RKjMl/lwIDAQABAkA5r4FJ6w+gh96j+Y1ds6j72b4JZdFAUaFS1zMZZc3R8KWWfMA+mjNoycrwJ+vH9wyUa+jMM/c/JTeYbOyz+DOpAiEA3Mnb8awvWle3ZrVpqELvlhrH25wlHxKnpy9pgAdHy90CIQDAgH8TuT8tLD1SE1QvMvw3N8UGlsOVxSnnar5YsZbMAwIhAK/L8lqNNO8EJL2c+NHG6ilkjXmo7E2/dspBkAkmwt3pAiEAsbBqnHwsMrhZSf+Jf5/ia93Qwko7821xRqmjVh9nAJ0CIBSwRT5cJkwUUPa/OQK9YptPnOiugFLsdiWuZzrQAqKQ";
    static final String MY_PUBLIC_KEY = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKYGN3xg1i9eo+O3Y61+F0Ql7jR0i7L/6tMddy/kMzemaTehK6KvaMGWwUhlp+GzJYkPD7tSPlxnsitESozJf5cCAwEAAQ==";

    static final Map<String, String> publicKeyMap = new HashMap<>();

    static{
        publicKeyMap.put("rf", RF_PUBLIC_KEY);
    }

    public static PublicKey getPublicKey(String rf){
        try {
            return RSAUtil.getPublicKey(publicKeyMap.get(rf));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static PrivateKey getPrivateKey(){
        try {
            return RSAUtil.getPrivateKey(MY_PRIVATE_KEY);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
